package com.base.cn.platform.os.service.course.catalog;

import com.base.cn.platform.os.entity.course.catalog.CourseCatalog;
import com.base.cn.platform.os.service.FeignAuthConfig;
import com.base.cn.platform.os.service.course.CourseBaseService;
import com.github.pagehelper.PageInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 课程目录接口
 *
 * @author s.li
 * @create 2018-04-26-19:42
 */
@FeignClient(name = CourseBaseService.appName, configuration = FeignAuthConfig.class)
public interface CourseCatalogService extends CourseBaseService {

    /**
     * 查询目录数量
     *
     * @param condition 查询条件
     * @return 数量
     */
    @RequestMapping(contextPath + "/getCourseCatalogCount")
    BigDecimal getCourseCatalogCount(@RequestBody Map<String, Object> condition);

    /**
     * 保存课程目录数据
     *
     * @param courseCatalog 课程对象
     * @return courseCatalog
     */
    @RequestMapping(contextPath + "/saveCourseCatalog")
    Map<String, Object> saveCourseCatalog(@RequestBody Map<String, Object> courseCatalog);

    /**
     * 给课程添加模块目录
     *
     * @param courseId 课程ID
     * @param mouldIds 模块ID串
     * @return Map<String , Object>
     */
    @RequestMapping(contextPath + "/saveCourseMould")
    Map<String, Object> saveCourseMould(@RequestParam("courseId") BigDecimal courseId,
                                        @RequestParam("mouldIds") String mouldIds);

    /**
     * 删除目录数据
     *
     * @param ids 目录ID串
     */
    @RequestMapping(contextPath + "/deleteCourseCatalogByIds")
    Map<String, Object> deleteCourseCatalogByIds(@RequestParam("ids") String ids);

    /**
     * 修改章节父级ID
     *
     * @param id       章节的ID
     * @param parentId 章节新的父级ID
     * @return Map<String , Object>
     */
    @RequestMapping(contextPath + "/updateCourseCatalogParent")
    Map<String, Object> updateCourseCatalogParent(@RequestParam("id") BigDecimal id,
                                                  @RequestParam("parentId") BigDecimal parentId);

    /**
     * 通过课程ID，查询课程的目录数据列表,并且分层
     *
     * @param buyCourseId     购买课程的ID
     * @param userId          用户ID
     * @param courseId        需要查询目录的课程ID
     * @param setMaterialData 是否设置素材数据
     * @param setLoresetPoint 设置知识点
     * @param setQuestion     设置试题
     * @param group           按题型分组
     * @param setPlayRecord   设置播放记录
     * @return List<CourseCatalog>
     */
    @RequestMapping(contextPath + "/findCourseCatalogLayeredByCourseId")
    List<Map<String, Object>> findCourseCatalogLayeredByCourseId(@RequestParam(value = "buyCourseId", required = false, defaultValue = "0") BigDecimal buyCourseId,
                                                                 @RequestParam("userId") BigDecimal userId,
                                                                 @RequestParam("courseId") BigDecimal courseId,
                                                                 @RequestParam("setMaterialData") boolean setMaterialData,
                                                                 @RequestParam("setLoresetPoint") boolean setLoresetPoint,
                                                                 @RequestParam("setQuestion") boolean setQuestion,
                                                                 @RequestParam("group") boolean group,
                                                                 @RequestParam("setPlayRecord") boolean setPlayRecord);

    /**
     * 通过课程ID，查询课程的目录数据列表
     *
     * @param courseId        设置ID
     * @param setMaterialData 是否设置素材数据
     * @param setLoresetPoint 设置考点数据
     * @param setQuestion     设置试题数据
     * @param group           按题型分组
     * @return List<CourseCatalog>
     */
    @RequestMapping(contextPath + "/findCourseCatalogByCourseId")
    List<Map<String, Object>> findCourseCatalogByCourseId(@RequestParam("courseId") BigDecimal courseId,
                                                          @RequestParam("setMaterialData") boolean setMaterialData,
                                                          @RequestParam("setLoresetPoint") boolean setLoresetPoint,
                                                          @RequestParam("setQuestion") boolean setQuestion,
                                                          @RequestParam("group") boolean group);

    /**
     * 通过ID查询目录数据
     *
     * @param id              ID
     * @param setMaterialData 是否设置素材数据
     * @param setLoresetPoint 设置考点数据
     * @param setQuestion     设置试题数据
     * @param group           按题型分组
     * @return CourseCatalog
     */
    @RequestMapping(contextPath + "/findCourseCatalogById")
    Map<String, Object> findCourseCatalogById(@RequestParam("id") BigDecimal id,
                                              @RequestParam("setMaterialData") boolean setMaterialData,
                                              @RequestParam("setLoresetPoint") boolean setLoresetPoint,
                                              @RequestParam("setQuestion") boolean setQuestion,
                                              @RequestParam("group") boolean group);

    /**
     * 通过ID串，查询目录数据
     *
     * @param ids             目录ID串
     * @param setMaterialData 是否设置素材数据
     * @param setLoresetPoint 设置考点数据
     * @param setQuestion     设置试题数据
     * @param group           按题型分组
     * @return List<CourseCatalog>
     */
    @RequestMapping(contextPath + "/findCourseCatalogByIds")
    List<Map<String, Object>> findCourseCatalogByIds(@RequestParam("ids") String ids,
                                                     @RequestParam("setMaterialData") boolean setMaterialData,
                                                     @RequestParam("setLoresetPoint") boolean setLoresetPoint,
                                                     @RequestParam("setQuestion") boolean setQuestion,
                                                     @RequestParam("group") boolean group);

    /**
     * 多条件查询目录数据
     *
     * @param condition       查询条件对象
     * @param setMaterialData 是否设置素材数据
     * @param setLoresetPoint 设置考点数据
     * @param setQuestion     设置试题数据
     * @param group           按题型分组
     * @return List<CourseCatalog>
     */
    @RequestMapping(contextPath + "/findCourseCatalogList")
    List<Map<String, Object>> findCourseCatalogList(@RequestBody Map<String, Object> condition,
                                                    @RequestParam("setMaterialData") boolean setMaterialData,
                                                    @RequestParam("setLoresetPoint") boolean setLoresetPoint,
                                                    @RequestParam("setQuestion") boolean setQuestion,
                                                    @RequestParam("group") boolean group);

    /**
     * 获取最新的目录
     *
     * @param courseIds 课程ID串
     * @return 最新的目录对象
     */
    @RequestMapping(contextPath + "/getNewCourseCatalog")
    Map<String, Object> getNewCourseCatalog(@RequestParam("courseIds") String courseIds);

    /**
     * 导出被选中的数据如果没有选中全部获取
     *
     * @param courseId 课程id
     * @param QueryIds 别选中的章节id串
     * @return
     */
    @RequestMapping(contextPath + "/findCourseCatalogListExcel")
    List<Map<String, Object>> findCourseCatalogListExcel(@RequestParam("courseId") BigDecimal courseId, @RequestParam(value = "QueryIds", required = false) String QueryIds);


    /**
     * 下载课程章节资料
     *
     * @param catalogId 课程章节id
     * @return
     */
    @RequestMapping(contextPath + "/downloadDatum")
    ResponseEntity<byte[]> downloadDatum(@RequestParam("catalogId") BigDecimal catalogId) throws Exception;

    /**
     * 调整节点排序
     *
     * @param currentId   要操作的节点ID
     * @param currentSort 操作的节点的新排序
     * @param oldId       被替换节点的ID
     * @param oldSort     被替换节点的排序
     * @return Map<String   ,   Object>
     */
    @RequestMapping(contextPath + "/updateNodeSort")
    void updateNodeSort(@RequestParam("currentId") BigDecimal currentId,
                        @RequestParam("currentSort") int currentSort,
                        @RequestParam("oldId") BigDecimal oldId,
                        @RequestParam("oldSort") int oldSort);

    /**
     * 评价数据导出
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(contextPath + "/downloadExcelDetailList")
    ResponseEntity<byte[]> downloadExcelDetailList(@RequestBody Map<String, Object> map) throws Exception;


    /**
     * 通过课程ID，查询课程的目录数据列表
     *
     * @param courseId 设置ID
     * @return List<CourseCatalog>
     */
    @RequestMapping(contextPath + "/findCourseCatalogPracticeByCourseId")
    List<Map<String, Object>> findCourseCatalogPracticeByCourseId(@RequestParam("courseId") BigDecimal courseId, @RequestParam("courseScoreRate") double courseScoreRate);

    @RequestMapping(contextPath + "/findCourseCatalogPage")
    List<CourseCatalog> findCourseCatalogPage(@RequestBody Map<String, Object> params);

    /**
     * 查询今日直播条数
     *
     * @param map
     * @return
     */
    @RequestMapping(contextPath + "/queryCurrentCount")
    Integer queryCurrentCount(@RequestBody Map<String, Object> map);

    /**
     * 获取用户的直播时间
     * @param dataKey
     * @param userId
     * @return
     */
    @RequestMapping(contextPath + "/findLiveTime")
    List<String> findLiveTime(@RequestParam("userId") BigDecimal userId);

}
